package com.lemon.smartsafetynew.ui.activity.notice;

import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.lemon.smartsafety.R;
import com.lemon.smartsafety.app.AppManager;
import com.lemon.smartsafetynew.ui.activity.base.PhotoSelectBaseActivity;
import com.lemon.smartsafetynew.ui.activity.contact.ChooseReceiverActivity;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * Created by Andrew on 2017/7/13.
 */

public class NoticeEditActivity extends PhotoSelectBaseActivity {

    @Bind(R.id.title_edit)
    EditText titleEdit;
    @Bind(R.id.content_edit)
    EditText contentEdit;
    @Bind(R.id.attachment_image)
    ImageView attachmentImage;
    @Bind(R.id.add_receiver_layout)
    LinearLayout addReceiverLayout;
    @Bind(R.id.lstop_layout)
    LinearLayout lstopLayout;
    @Bind(R.id.radio_btn)
    ImageView radioBtn;

    @Override
    protected void initTitle() {

        if (mToolBar != null) {
            mToolBar.setContentInsetsAbsolute(0, 0);
        }
        setBarTitle(R.string.inner_notice_label);
    }

    @Override
    protected void callFinish() {
        AppManager.getAppManager().finishActivity(this);
    }

    @Override
    protected int getContentViewId() {
        return R.layout.activity_notice_edit;
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        setIconEnable(menu, true);
        getMenuInflater().inflate(R.menu.menu_toolbar, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.action_publish: {
                Log.i("yxy", "R.id.action_publish");
                break;
            }
        }
        return super.onOptionsItemSelected(item);
    }


    @Override
    protected void initViews() {
        super.initViews();

        radioBtn.setSelected(true); // 公告置顶是默认选中的

    }

    @OnClick({R.id.attachment_image, R.id.add_receiver_layout, R.id.lstop_layout})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.attachment_image:
                // 添加附件

                break;
            case R.id.add_receiver_layout:
                // 添加接受者
                Intent mIntent = new Intent(NoticeEditActivity.this, ChooseReceiverActivity.class);
                startActivity(mIntent);
                break;
            case R.id.lstop_layout:
                radioBtn.setSelected(!radioBtn.isSelected());
                break;
        }
    }
}
